Skip to content

Fix dependency injection PHP sample code #17199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2022
Merged

Fix dependency injection PHP sample code #17199

merged 1 commit into from
Aug 22, 2022

Conversation

jdecool
Copy link
Contributor

@jdecool jdecool commented Aug 17, 2022

I've just noticed that there is an error in the code sample:

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
    $container->parameters()
        // ...
        ->set('mailer.transport', 'sendmail')
    ;

    $container->services()
        ->set('mailer', 'Mailer')
            ->args(['%mailer.transport%'])

    $services->set('mailer', 'Mailer')
        // the param() method was introduced in Symfony 5.2.
        ->args([param('mailer.transport')])
    ;

    $services->set('newsletter_manager', 'NewsletterManager')
        // In versions earlier to Symfony 5.1 the service() function was called ref()
        ->call('setMailer', [service('mailer')])
    ;
};

The $services is not defined.

@carsonbot carsonbot added this to the 5.4 milestone Aug 17, 2022
@xabbuh
Copy link
Member

xabbuh commented Aug 22, 2022

Good catch, thanks @jdecool.

@xabbuh xabbuh merged commit d6392af into symfony:5.4 Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants